package org.foj.model {
import mx.collections.ICollectionView;

public class PieChartModel {

  private var colors:Array = [
    0x468966,
    0xFFB03B,
    0xFFF0A5,
    0x999574,
    0x007D9F,
    0x8E2800,
    0x8E28F4,
    0x0528F4,
    0xF42105,
    0x0CF405,
    0xF6FF00
  ];

  public function PieChartModel() {

  }

  public function getLegendColorForIndex(index:Number):Number {
    return colors[index];
  }

  public function getAngleForItem(units:Number, totalUnits:Number):Number {
    return ((units / totalUnits)  * 360);
  }

  public function getTotalUnits(dataProvider:ICollectionView):Number {
    var total:Number = 0;

    for each(var item:Object in dataProvider) {
      total += item.units;
    }

    return total;
  }
}
}